<template>
    <div class="goods-pingjia-edit">
        <div class="goods-pingjia-edit-card">
            <Row :gutter="20">
                <Col span="12" type="flex" justify="center">
                <!--左边列表-->
                <Row :gutter="0">
                    <Col span="6" class="list"><a>订单号:</a></Col><Col span="18" class="list"><p>{{details.orderno}}</p></Col>
                    <Col span="6" class="list"><a>商品名称:</a></Col><Col span="18" class="list"><p>{{details.goodsname}}</p></Col>
                    <Col span="6" class="list"><a>用户:</a></Col><Col span="18" class="list"><p>{{details.username}}</p></Col>
                    <Col span="6" class="list"><a>状态:</a></Col><Col span="18" class="list">
                        <RadioGroup v-model="isShow">
                            <Radio label="1">
                                <Icon type="eye"></Icon>
                                <span>显示</span>
                            </Radio>
                            <Radio label="-1">
                                <Icon type="eye-disabled"></Icon>
                                <span>隐藏</span>
                            </Radio>
                        </RadioGroup>
                    </Col>
                    <Col span="6" class="listHeight lineH"><a>评价:</a></Col><Col span="18" class="listHeight">
                    <!--商品评价-->
                    <p>
                        <span>商品评价 :</span>
                        <a  v-for="(key,value) in goodsscore" @click="setOne(value+1)">
                            <Icon type="android-star" :color="key?'':'#c3c3c3'" size="25" style="margin-right: 3px;"/>
                        </a>
                    </p>
                    <!--时效评价-->
                    <p>
                        <span>时效评价 :</span>
                        <a  v-for="(key,value) in timescore" @click="setTwo(value+1)">
                            <Icon type="android-star" :color="key?'':'#c3c3c3'" size="25" style="margin-right: 3px;"/>
                        </a>
                    </p>
                    <!--服务评价-->
                    <p>
                        <span>服务评价 :</span>
                        <a  v-for="(key,value) in servicescore" @click="setThree(value+1)">
                            <Icon type="android-star" :color="key?'':'#c3c3c3'" size="25" style="margin-right: 3px;"/>
                        </a>
                    </p>
                    </Col>
                    <Col span="6" class="listHeight lineH"><a>评语:</a></Col><Col span="18" class="listHeight">
                        <Input :maxlength="300" style="margin-top: 2px;" v-model="value6" :autosize="{minRows: 5,maxRows: 5}" type="textarea" :rows="4" placeholder="评语内容"></Input>
                    </Col>
                </Row>
                </Col>
                <Col span="12">
                <!--右边图标-->
                <Card>
                    <img class="goodsIcon" :src="details.goodsimg"/>
                </Card>
                </Col>
            </Row>
            <Button type="primary" class="sub" @click="sub">提交</Button>
        </div>
    </div>
</template>
<script>
    export default {
        name:"goods-pingjia-edit",
        data(){
            return{
                details:{},
                goodsscore:[true,false,false,false,false],
                timescore:[true,false,false,false,false],
                servicescore:[true,false,false,false,false],
                isShow:"1",
                one:1,
                two:1,
                three:1,
                value6:""
            }
        },
        mounted(){
            this.getOne()
        },
        methods:{
            getOne(){
                this.getJsonData("Appraises/getOne",{id:this.$route.query.id})
                    .then((res)=>{
                        this.details=res.data
                        this.value6=res.data.content
                        this.one=parseInt(res.data.goodsscore)
                        this.two=parseInt(res.data.timescore)
                        this.three=parseInt(res.data.servicescore)
                        for(var i=0;i<parseInt(res.data.goodsscore);i++){
                            this.goodsscore.splice(i,1,true)
                        }
                        for(var i=0;i<parseInt(res.data.timescore);i++){
                            this.timescore.splice(i,1,true)
                        }
                        for(var i=0;i<parseInt(res.data.servicescore);i++){
                            this.servicescore.splice(i,1,true)
                        }
                    })
            },
            setOne(n){
                this.goodsscore=[false,false,false,false,false]
                for(let i=0;i<parseInt(n);i++){
                    this.goodsscore.splice(i,1,true)
                }
                this.one=n
            },
            setTwo(n){
                this.timescore=[false,false,false,false,false]
                for(let i=0;i<parseInt(n);i++){
                    this.timescore.splice(i,1,true)
                }
                this.two=n
            },
            setThree(n){
                this.servicescore=[false,false,false,false,false]
                for(let i=0;i<parseInt(n);i++){
                    this.servicescore.splice(i,1,true)
                }
                this.three=n
            },
            sub(){
                this.$Loading.start()
                this.getJsonData("Appraises/changeAppraises",{
                    id:this.$route.query.id,
                    goodsScore:this.one,
                    timeScore:this.two,
                    serviceScore:this.three,
                    content:this.value6,
                    isShow:this.isShow,
                })
                    .then((res)=>{
                        this.$Message.success("修改成功")
                    })
            }
        }
    }
</script>
<style lang="less">
    @import "./goods-pingjia-edit";
</style>